home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 51 / Mac Magazin and MacEasy Magazine CD - Issue 51.iso / Updates / E-Tech Gold 56K modem / MAC CCL Modem Script / E56KRX.sea / E56KRX next >
Text File  |  1998-10-16  |  11KB  |  582 lines

  1. !  E56KRX
  2. !    Author:    Kris Kreutzman
  3. !
  4. !    Copyright:    © 1991-1996 Apple Computer, Inc.    All Rights Reserved.
  5. !
  6. !    revision history:
  7. !        v2.1    as shipped with the ARA 2.1
  8. !
  9. !  'mlts' resource info for this modem:
  10. !    byte 1 == 01 -> modem HAS built-in error correction protocols
  11. !    byte 2 == 01 -> modem HAS built-in data compression protocols
  12. !    byte 3 == 40 -> max number of chars in varstr 7
  13. !    byte 4 == 40 -> max number of chars in varstr 8
  14. !    byte 5 == 40 -> max number of chars in varstr 9
  15. !    
  16. @ORIGINATE
  17. @ANSWER
  18. !
  19. ! ---- Initial modem setup ----
  20. !
  21. ! Set serial port speed depending upon the compression flag
  22. !    A higher rate with compression on to handle expanded data from the modem
  23. !    A lower rate closer to the DCE when compression is off
  24. ifstr 5 1 "0"
  25. serreset 115200, 0, 8, 1
  26. jump 2
  27. !
  28. @LABEL 1
  29. serreset 57600, 0, 8, 1
  30. !
  31. @LABEL 2
  32. hsreset 0 0 0 0 0 0
  33. settries 0
  34. !
  35. ! Get the modem's attention
  36. !
  37. matchclr
  38. matchstr 1 3 "OK\13\10"
  39. write "AT\13"
  40. matchread 30
  41. !
  42. @LABEL 3
  43. !
  44. ! Setup the modem for the following:
  45. !   Reset to factory settings
  46. !   Standard compression/reliablity
  47. !   Lock serial port speed
  48. !   Serial port hardware handshaking, turn off software handshaking
  49. !   Verbose responces and compression/protocol results
  50. !   CONNECT returns DCE speed
  51. !   Turn off answering
  52. !   Reset or return to command mode on DTR toggle (optional)
  53. !
  54. matchclr
  55. matchstr 1 4   "OK\13\10"
  56. matchstr 2 101 "ERROR\13\10"
  57. write "AT&F&C1&D2E0W2S0=0S95=45\13"
  58. matchread 30
  59. inctries
  60. iftries 3 101
  61. !
  62. ! Reset the Modem on setup failure
  63. !
  64. DTRClear
  65. pause 5
  66. DTRSet
  67. flush
  68. jump 3
  69. !
  70. !
  71. @LABEL 4
  72. ! Varstring 4 , reliable link protocol:
  73. !    = 0, handled by computer (ARAP)
  74. !    = 1, handled by modem (PPP)
  75. !    = 2, MNP10 protocol (Cellular protocol, no longer supported)
  76. ifstr 4 5 "1"
  77. ifstr 4 5 "2"
  78. !
  79. ! Varstring 4 == 0, turn off reliable link protocol in modem (ARAP)
  80. matchclr
  81. matchstr 1 9 "OK\13\10"
  82. write "AT\\N0\13"
  83. matchread 30
  84. jump 101
  85. !
  86. !
  87. @LABEL 5
  88. ! Varstring 5, compression protocol:
  89. !    = 0, handled by computer 
  90. !    = 1, handled by modem
  91. ifstr 5 9 "1"
  92. !
  93. ! Varstring 5 == 0, turn off compression protocol in modem.
  94. matchclr
  95. matchstr 1 9 "OK\13\10"
  96. write "AT%C0\13"
  97. matchread 30
  98. jump 101
  99. !
  100. !
  101. @LABEL 9
  102. ! Varstring 2, modem speaker:
  103. !    = 0, speaker off
  104. !    = 1, speaker on
  105. ifstr 2 13 "1"
  106. pause 5
  107. matchclr
  108. matchstr 1 13 "OK\13\10"
  109. write "ATM0\13"
  110. matchread 30
  111. jump 101
  112. !
  113. ! Modem ready, wait for a call or originate a call
  114. !
  115. @LABEL 13
  116. ifANSWER 32
  117. !
  118. !
  119. ! ---- Originating a call ----
  120. !
  121. ! Varstring 6, dialing mode:
  122. !    = 0, normal dialing
  123. !    = 1, blind dialing
  124. !    = 2, manual dialing
  125. ifstr 6 17 "1"
  126. ifstr 6 15 "2"
  127. jump 19
  128. !
  129. @LABEL 15
  130. ! Display ASK dialog with message.  Goto label 107 if dialog canceled.
  131. ASK 2 "Pick up the phone & dial ^1.  Hit OK when the phone rings, then hangup." 107
  132. note "Manual dialing initiated" 3
  133. ! X1 to ignore dialtone & busy, D to dial, \^ generates data tone
  134. write "ATX1D\^\13"
  135. jump 32
  136. !
  137. @LABEL 17
  138. note "Dialing without tone" 3
  139. matchclr
  140. matchstr 1 19 "OK\13\10"
  141. ! X1 to ignore dialtone & busy
  142. write "ATX1\13"
  143. matchread 30
  144. jump 101
  145. !
  146. !
  147. @LABEL 19
  148. ! Display the full dialstring contained in Varstring 1
  149. note "Dialing ^1" 3
  150. !
  151. ! Varstrings 7, 8 and 9, contain dialstring fragments
  152. !    Long phone numbers may need to be split into smaller groups
  153. !    for the modem to use
  154. !
  155. ! Varstring 3:  "p" for pulse & "t" for tone dialing
  156. ! Varstring 8 == blank (dialstring in varstring 7)
  157. ! Varstring 9 == blank (dialstring in varstrings 7 & 8)
  158. ! Otherwise (dialstring in varstrings 7, 8 & 9)
  159. ! \^ is added to the dialstring to force the modem to generate a data tone
  160. ifstr 8 27 " "
  161. ifstr 9 24 " "
  162. !
  163. !  Write dialstring in varstrings 7, 8 & 9
  164. matchclr
  165. matchstr 1 21 "OK\13\10"
  166. write "ATD^3\^^7;\13"
  167. matchread 400
  168. jump 101
  169.  
  170. @LABEL 21
  171. matchclr
  172. matchstr 1 22 "OK\13\10"
  173. write "ATD^3^8;\13"
  174. matchread 400
  175. jump 101
  176.  
  177. @LABEL 22
  178. write "ATD^3^9\13"
  179. jump 32
  180. !
  181. !
  182. @LABEL 24
  183. !  Write dialstring in varstrings 7 & 8
  184. matchclr
  185. matchstr 1 25 "OK\13\10"
  186. write "ATD^3\^^7;\13"
  187. matchread 400
  188. jump 101
  189.  
  190. @LABEL 25
  191. write "ATD^3^8\13"
  192. jump 32
  193. !
  194. @LABEL 27
  195. !  Write dialstring in varstring 7
  196. write "ATD^3\^^7\13"
  197. !
  198. !
  199. !    ---- Connection responce ----
  200. !
  201. ! The following section will parse modem responces of two types:
  202. !   1) PROTOCOL: xxx, COMPRESSION: xxx, CONNECT xxx
  203. !   2) CONNECT xxx/ARQ/V42
  204. !
  205. @LABEL 32
  206. matchclr
  207. matchstr  1 81  "RING\13\10"
  208. matchstr  2 102 "NO DIALTONE\13\10"
  209. matchstr  3 103 "NO CARRIER"
  210. matchstr  4 103 "ERROR\13\10"
  211. matchstr  5 104 "BUSY\13\10"
  212. matchstr  6 105 "NO ANSWER\13\10"
  213. matchstr  7 33  "CONNECT "
  214. matchstr  8 32  "CARRIER"
  215. matchstr  9 40  "CONNECT\13\10"
  216. matchstr 10 62  "PROTOCOL: LAP"
  217. matchstr 11 62  "PROTOCOL: MNP"
  218. matchstr 12 62  "PROTOCOL: ALT"
  219. matchstr 13 67  "COMPRESSION: V"
  220. matchstr 14 67  "COMPRESSION: MNP5"
  221. matchstr 15 67  "COMPRESSION: CLASS"
  222. matchread 700
  223. ifANSWER 32
  224. jump 101
  225. !
  226. !  Parse the speed of connect result codes
  227. !  2400 and 4800 have two entries each
  228. !  to distinguish them from 24000 and 48000
  229. !
  230. @LABEL 33
  231. matchclr
  232. matchstr  1 40 "2400\13"
  233. matchstr  2 40 "2400/"
  234. matchstr  3 41 "4800\13"
  235. matchstr  4 41 "4800/"
  236. matchstr  5 42 "7200"
  237. matchstr  6 43 "9600"
  238. matchstr  7 44 "12000"
  239. matchstr  8 45 "14400"
  240. matchstr  9 46 "16800"
  241. matchstr 10 47 "19200"
  242. matchstr 11 48 "21600"
  243. matchstr 12 49 "24000"
  244. matchstr 13 50 "26400"
  245. matchstr 14 51 "28800"
  246. matchstr 15 52 "31200"
  247. matchstr 16 53 "33600"
  248. matchstr 17 54 "38400"
  249. matchstr 18 55 "48000"
  250. matchstr 19 56 "56000"
  251. matchstr 20 57 "57600"
  252. matchstr 21 58 "64000"
  253. matchstr 22 108 "32000"
  254. matchstr 23 109 "34000"
  255. matchstr 24 110 "36000"
  256. matchstr 25 111 "38000"
  257. matchstr 26 112 "40000"
  258. matchstr 27 113 "42000"
  259. matchstr 28 114 "44000"
  260. matchstr 29 115 "46000"
  261. matchstr 30 116 "50000"
  262. matchstr 31 117 "52000"
  263. matchstr 32 118 "54000"
  264. matchread 30
  265. jump 59
  266. !
  267. ! -- Connection rates --
  268. ! CommunicatingAt informs ARA of the raw modem to modem
  269. ! connection speed.
  270. !
  271. @LABEL 40
  272. note "Communicating at 2400 bps." 2
  273. CommunicatingAt 2400
  274. jump 60
  275. !
  276. @LABEL 41
  277. note "Communicating at 4800 bps." 2
  278. CommunicatingAt 4800
  279. jump 60
  280. !
  281. @LABEL 42
  282. note "Communicating at 7200 bps." 2
  283. CommunicatingAt 7200
  284. jump 60
  285. !
  286. @LABEL 43
  287. note "Communicating at 9600 bps." 2
  288. CommunicatingAt 9600
  289. jump 60
  290. !
  291. @LABEL 44
  292. note "Communicating at 12400 bps." 2
  293. CommunicatingAt 12400
  294. jump 60
  295. !
  296. @LABEL 45
  297. note "Communicating at 14400 bps." 2
  298. CommunicatingAt 14400
  299. jump 60
  300. !
  301. @LABEL 46
  302. note "Communicating at 16800 bps." 2
  303. CommunicatingAt 16800
  304. jump 60
  305. !
  306. @LABEL 47
  307. note "Communicating at 19200 bps." 2
  308. CommunicatingAt 19200
  309. jump 60
  310. !
  311. @LABEL 48
  312. note "Communicating at 21600 bps." 2
  313. CommunicatingAt 21600
  314. jump 60
  315. !
  316. @LABEL 49
  317. note "Communicating at 24000 bps." 2
  318. CommunicatingAt 24000
  319. jump 60
  320. !
  321. @LABEL 50
  322. note "Communicating at 26400 bps." 2
  323. CommunicatingAt 26400
  324. jump 60
  325. !
  326. @LABEL 51
  327. note "Communicating at 28800 bps." 2
  328. CommunicatingAt 28800
  329. jump 60
  330. !
  331. @LABEL 52
  332. note "Communicating at 31200 bps." 2
  333. CommunicatingAt 31200
  334. jump 60
  335. !
  336. @LABEL 53
  337. note "Communicating at 33600 bps." 2
  338. CommunicatingAt 33600
  339. jump 60
  340. !
  341. @LABEL 54
  342. note "Communicating at 38400 bps." 2
  343. CommunicatingAt 38400
  344. jump 60
  345. !
  346. @LABEL 55
  347. note "Communicating at 48000 bps." 2
  348. CommunicatingAt 48000
  349. jump 60
  350. !
  351. @LABEL 56
  352. note "Communicating at 56000 bps." 2
  353. CommunicatingAt 56000
  354. jump 60
  355. !
  356. @LABEL 57
  357. note "Communicating at 57600 bps." 2
  358. CommunicatingAt 57600
  359. jump 60
  360. !
  361. @LABEL 58
  362. note "Communicating at 64000 bps." 2
  363. CommunicatingAt 64000
  364. jump 60
  365. !
  366. @LABEL 108
  367. note "Communicating at 32000 bps." 2
  368. CommunicatingAt 32000
  369. jump 60
  370. !
  371. @LABEL 109
  372. note "Communicating at 34000 bps." 2
  373. CommunicatingAt 34000
  374. jump 60
  375. !
  376. @LABEL 110
  377. note "Communicating at 36000 bps." 2
  378. CommunicatingAt 36000
  379. jump 60
  380. !
  381. @LABEL 111
  382. note "Communicating at 38000 bps." 2
  383. CommunicatingAt 38000
  384. jump 60
  385. !
  386. @LABEL 112
  387. note "Communicating at 40000 bps." 2
  388. CommunicatingAt 40000
  389. jump 60
  390. !
  391. @LABEL 113
  392. note "Communicating at 42000 bps." 2
  393. CommunicatingAt 42000
  394. jump 60
  395. !
  396. @LABEL 114
  397. note "Communicating at 44000 bps." 2
  398. CommunicatingAt 44000
  399. jump 60
  400. !
  401. @LABEL 115
  402. note "Communicating at 46000 bps." 2
  403. CommunicatingAt 46000
  404. jump 60
  405. !
  406. @LABEL 116
  407. note "Communicating at 50000 bps." 2
  408. CommunicatingAt 50000
  409. jump 60
  410. !
  411. @LABEL 117
  412. note "Communicating at 52000 bps." 2
  413. CommunicatingAt 52000
  414. jump 60
  415. !
  416. @LABEL 118
  417. note "Communicating at 54000 bps." 2
  418. CommunicatingAt 54000
  419. jump 60
  420. !
  421. @LABEL 59
  422. note "Communicating at an unknown rate." 2
  423. jump 60
  424. !
  425. ! Look for reliablilty and compression results 
  426. ! at the end of the connect result.
  427. !
  428. @LABEL 60
  429. matchclr
  430. matchstr  1 63 "LAPM"
  431. matchstr  2 63 "REL"
  432. matchstr  3 63 "ARQ"
  433. matchstr  4 68 "COMP/"
  434. matchstr  5 68 "COMP\13"
  435. matchstr  6 63 "V42/"
  436. matchstr  7 63 "V42\13"
  437. matchstr  8 68 "V42BIS"
  438. matchstr  9 68 "V42bis"
  439. matchstr 10 63 "MNP\13"
  440. matchstr 11 68 "MNP5"
  441. matchstr 12 70 "\10"
  442. matchread 30
  443. jump 70
  444.  
  445. ! -- Modem error correction link negotiation --
  446. ! Userhook 2 informs ARA that a modem-to-modem error
  447. ! correcting protocol has been negotiated
  448. !
  449. !
  450. @LABEL 62
  451. note "Modem Reliable Link Established." 2
  452. userhook 2
  453. jump 32
  454. !
  455. @LABEL 63
  456. note "Modem Reliable Link Established." 2
  457. userhook 2
  458. jump 60
  459. !
  460. ! -- Compression negotiation --
  461. ! Userhook 3 informs ARA that a modem-to-modem compression
  462. ! protocol has been negotiated
  463. !
  464. @LABEL 67
  465. note "Modem Compression Established." 2
  466. userhook 3
  467. jump 32
  468. !
  469. @LABEL 68
  470. note "Modem Compression Established." 2
  471. userhook 3
  472. jump 60
  473. !
  474. !
  475. ! -- Normal exit after "CONNECT" --
  476. !
  477. !  This modem has been setup to do CTS handshaking,
  478. !  and we assume that a CTS handshaking cable is being used.
  479. !
  480. @LABEL 70
  481. ! Turn on CTS handshaking.
  482. HSReset 0 1 0 0 0 0
  483. !
  484. ifANSWER 71
  485. pause 30
  486. @LABEL 71
  487. exit 0
  488. !
  489. !
  490. ! ---- Answer calls ----
  491. !
  492. !    A RING result from the modem and in ANSWERING mode
  493. !    claims the serial port and answering the phone
  494. !
  495. @LABEL 81
  496. ifORIGINATE 32
  497. userhook 1
  498. note "Answering phone..." 2
  499. write "ATA\13"
  500. jump 32
  501. !
  502. !
  503. ! ---- Hang up and reset modem ----
  504. !
  505. @HANGUP
  506. @LABEL 90
  507. settries 0
  508. HSReset 0 0 0 0 0 0
  509. !
  510. @LABEL 92
  511. !  Escape from data to command mode
  512. matchclr
  513. matchstr 1 96 "OK\13\10"
  514. write "+++"
  515. matchread 20
  516. !
  517. @LABEL 94
  518. ! Force a hangup
  519. matchclr
  520. matchstr 1 98 "NO CARRIER\13\10"
  521. matchstr 2 98 "OK\13\10"
  522. matchstr 3 98 "ERROR\13\10"
  523. matchstr 4 98 "0\13\10"
  524. write "ATH\13"
  525. matchread 30
  526. ! Try to get control of the modem by toggling DTR
  527. DTRClear
  528. pause 5
  529. DTRSet
  530. flush
  531. !
  532. ! Try the hangup sequence three times otherwise declare and error
  533. inctries
  534. iftries 3 101
  535. jump 92
  536. !
  537. @LABEL 96
  538. ! Pause between data and command mode
  539. pause 50
  540. jump 94
  541. !
  542. !
  543. @LABEL 98
  544. ! Recall the factory settings
  545. pause 15
  546. matchclr
  547. matchstr 1 99 "OK\13\10"
  548. write "AT&F\13"
  549. matchread 30
  550. jump 101
  551. !
  552. @LABEL 99
  553. exit 0
  554. !
  555. ! ---- Error messages -----
  556. !
  557. ! Modem Not Responding
  558. @LABEL 101
  559. exit -6019
  560. !
  561. ! No Dial Tone
  562. @LABEL 102
  563. exit -6020
  564. !
  565. ! No Carrier or Error
  566. @LABEL 103
  567. exit -6021
  568. !
  569. ! Busy
  570. @LABEL 104
  571. exit -6022
  572. !
  573. ! No Answer
  574. @LABEL 105
  575. exit -6023
  576. !
  577. ! User Cancellation
  578. @LABEL 107
  579. exit -6008
  580.